

import com.jason.tag.config.ConfigTag;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceUnit;

/**
 *
 * @author Jason
 */
@ManagedBean
@ApplicationScoped
public class AppDataSources {

    
    private EntityManagerFactory emf;
    private EntityManager em;

    public AppDataSources() {
        emf = Persistence.createEntityManagerFactory(ConfigTag.PERSISTENCE_UNIT_NAME);
        em = emf.createEntityManager();
    }

    public EntityManager getEm() {
        return em;
    }
    
    public void refreshEMF(){
        emf.getCache().evictAll();
    }
}
